package com.spyx.home.controller;

import com.spyx.auth.AuthContextHolder;
import com.spyx.home.service.ItemService;
import com.spyx.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/home")
public class ItemApiController {

    @Autowired
    private ItemService itemService;

    @GetMapping("/item/{skuid}")
    public Result item(@PathVariable("skuid")Long skuId){
        Long userId = AuthContextHolder.getUserId();
        Map map=  itemService.item(skuId, userId);
        return Result.ok(map);
    }
}
